package com.yzw.hello.model.pojos.system.user;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.yzw.hello.model.pojos.system.role.Role;

@Entity
@Table(name = "user")
public class User {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	
	@Column(nullable = false, updatable = true, length = 50)
	@NotNull
	@Length(max = 50, message = "名称不能超过{max}")
	private String name;
	
	@Column(nullable = false, updatable = true, length = 50)
	@NotNull
	@Length(max = 50, message = "名称不能超过{max}")
	private String account;
	
	@Column(nullable = false, updatable = true, length = 50)
	@NotNull
	@Length(max = 50, message = "名称不能超过{max}")
	private String password;
	
	@ManyToMany(mappedBy = "users",cascade = CascadeType.ALL)
	private Set<Role> roles;
	
	@OneToOne
	@JoinColumn(name = "uid")
	private UserInfo userInfo;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public UserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfo userinfo) {
		this.userInfo = userinfo;
	}
	
}
